/*
 * Copyright 2012-2014 Manlost.com All right reserved. This software is the confidential and proprietary information of
 * Manlost.com ("Confidential Information"). You shall not disclose such Confidential Information and shall use it only
 * in accordance with the terms of the license agreement you entered into with Manlost.com.
 */
package com.manlost.biz.account.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.manlost.biz.account.AccountService;
import com.manlost.biz.account.impl.dao.interfaces.AccountDAO;
import com.manlost.biz.account.model.dataobject.Account;
import com.manlost.biz.argument.Argument;

/**
 * AccountService实现描述
 * 
 * @author kang.zhouk
 */
@Service
public class AccountServiceImpl implements AccountService {

    @Autowired
    private AccountDAO accountDAO;

	@Override
	public Account findManLostUser(String email) {
		Argument.isNotNull(email, "findManLostUser", "email", "null");
		
		return accountDAO.findAccount(email);
	}

	@Override
	public Account createManLostUser(Account account) {
		Argument.isNotNull(account, "createManLostUser", "Account object", "null");
		
		Account accountDB = accountDAO.findAccount(account.getEmail());
		Argument.isNull(accountDB, "createManLostUser", "Account with email: " + account.getEmail() + "is already exist!", "null");
		
		return accountDAO.createAccount(account);
	}
}
